﻿using KELT.KELTObjects.ViewportObjectModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KELT.AutoText
{
    /// <summary>
    /// AutoTextWindow.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class AutoTextWindow : Window
    {
        private TOOL mainContext;
        public AutoTextWindow(TOOL mainContext)
        {
            InitializeComponent();
            this.mainContext = mainContext;
        }

        private void Option1_MouseDown(object sender, MouseButtonEventArgs e)
        {
            double x = mainContext.mainViewport.RenderSize.Width/2;
            double y = mainContext.mainViewport.RenderSize.Height/2;
            for(int i=0; i<mainContext.viewPortMgr.ObjectList.Count; i++)
            {
                ViewportObj viewportObj = mainContext.viewPortMgr.ObjectList.ElementAt(i);
                viewportObj.setXYZ(mainContext, mainContext.mainViewport.RenderSize, x, y, 0);
            }
        }
        private void Option2_MouseDown(object sender, MouseButtonEventArgs e)
        {
            double x = mainContext.mainViewport.RenderSize.Width / 2;
            double y = 0;
            for (int i = 0; i < mainContext.viewPortMgr.ObjectList.Count; i++)
            {
                ViewportObj viewportObj = mainContext.viewPortMgr.ObjectList.ElementAt(i);
                viewportObj.setXYZ(mainContext, mainContext.mainViewport.RenderSize, x, (100*i), 0);
            }

        }
        private void Option3_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Random rand = new Random();
            int width = (int)mainContext.mainViewport.RenderSize.Width;
            int height = (int)mainContext.mainViewport.RenderSize.Height;
            
            for (int i = 0; i < mainContext.viewPortMgr.ObjectList.Count; i++)
            {
                int x = rand.Next(width);
                int y = rand.Next(height);
                ViewportObj viewportObj = mainContext.viewPortMgr.ObjectList.ElementAt(i);
                viewportObj.setXYZ(mainContext, mainContext.mainViewport.RenderSize, x, y, 0);
            }

        }
        private void Option4_MouseDown(object sender, MouseButtonEventArgs e)
        {

            double x = mainContext.mainViewport.RenderSize.Width / 2;
            double y = mainContext.mainViewport.RenderSize.Height / 2;
            for (int i = 0; i < mainContext.viewPortMgr.ObjectList.Count; i++)
            {
                ViewportObj viewportObj = mainContext.viewPortMgr.ObjectList.ElementAt(i);
                viewportObj.setXYZ(mainContext, mainContext.mainViewport.RenderSize, (300 * i), y, 0);
            }

        }

        private void Option5_MouseDown(object sender, MouseButtonEventArgs e)
        {


            Random rand = new Random();
            int width = (int)mainContext.mainViewport.RenderSize.Width;
            int height = (int)mainContext.mainViewport.RenderSize.Height;

            for (int i = 0; i < mainContext.viewPortMgr.ObjectList.Count; i++)
            {
                int x = rand.Next(width);
                int y = rand.Next(height);
                ViewportObj viewportObj = mainContext.viewPortMgr.ObjectList.ElementAt(i);
                viewportObj.setXYZ(mainContext, mainContext.mainViewport.RenderSize, x, y, 0);
            }

        }
    }
}
